﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Routing;
using WoBian.Entities;
using WoBian.Logic.Admin.User;
using WoBian.Entities.DataContract;
using WoBian.ServiceModel;

namespace WoBian.Models.Admin.Login
{
    public class AdminLoginModel
    {
        /// <summary>
        /// 登录名
        /// </summary>
        public string LoginName { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get; set; }

        /// <summary>
        /// 管理员密码
        /// </summary>
        public string AdminPassword { get; set; }

        /// <summary>
        /// 验证码
        /// </summary>
        public string ValidateCode { get; set; }

        public AdminUserLoginInfoDataContract Login()
        {
            var aDC = ToLoginDataContract();
            AdminUserLoginInfoDataContract aInfo = new AdminUserLoginInfoDataContract();
            if(ValidateCode.ToLower()!=MyApplicationContext.Current.ValidateCode.ToLower())
            {
                aInfo.LoginStatus = Lib.Enum.LoginStatusEnum.ValidateCodeError;
            }
            else
            {
                aInfo = AdminUserLogic.Login(aDC);
            }
            return aInfo;
        }

        private LoginDataContract ToLoginDataContract()
        {
            LoginDataContract aDC = new LoginDataContract { LoginName = this.LoginName, Password = this.Password, AdminPassword = this.AdminPassword };
            return aDC;
        }


    }
}
